using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Controls
{
    public class BasePageControl : System.Web.UI.Page
    {
        EventHandler UserLoggedInDelegate;
        EventHandler UserLoggedOutDelegate;

        public void Page_PreInit(object sender, EventArgs e)
        {
            UserLoggedInDelegate += new EventHandler(UserLoggedIn);
            UserLoggedOutDelegate += new EventHandler(UserLoggedOut);
            Managers.UserLoginManager.Instance.OnUserLoggedIn += UserLoggedInDelegate;
            Managers.UserLoginManager.Instance.OnUserLoggedOut += UserLoggedOutDelegate;
        }

        public override void Dispose()
        {
            Managers.UserLoginManager.Instance.OnUserLoggedIn -= UserLoggedInDelegate;
            Managers.UserLoginManager.Instance.OnUserLoggedOut -= UserLoggedOutDelegate;
            base.Dispose();
        }

        public virtual void UserLoggedIn(object sender, EventArgs e)
        { }

        public virtual void UserLoggedOut(object sender, EventArgs e)
        { }

        public void RedirectHome()
        {
            HttpContext.Current.Response.Redirect(Forum.SiteSettings.GetRelativePath("default.aspx"));
        }
    }
}